package 设计模式.备忘录模式;

public class Client {
    public static void main(String[] args) {
        Originator originator = new Originator();
        Caretaker caretaker = new Caretaker();

        originator.setState("状态1#攻击力100");
        //通过caretaker 保存状态1
        caretaker.add(originator.saveStateMemento());

        originator.setState("状态2#攻击力80");
        //保存状态2
        caretaker.add(originator.saveStateMemento());

        originator.setState("状态3#攻击力50");
        //保存状态3
        caretaker.add(originator.saveStateMemento());
        System.out.println("当前状态3的状态是="+originator.getState());

        //现在希望得到状态1，将originator恢复到状态1
        originator.getStateFromMemento(caretaker.get(0));
        System.out.println("恢复到状态1后的状态是="+originator.getState());
    }
}
